package LC34;

import java.util.HashSet;

public class LC3396 {

    public int minimumOperations(int[] nums) {
        int length = nums.length;

        HashSet<Integer> set = new HashSet<>();
        for (int i = length - 1; i >= 0; i--) {
            int num = nums[i];
            if (!set.contains(num)) {
                set.add(num);
            } else {
                return (i + 1) % 3 == 0 ? (i + 1) / 3 : (i + 1) / 3 + 1;
            }
        }
        return 0;
    }
}
